package leecode

func selfDividingNumbers(left int, right int) []int {
	result := make([]int, 0, right-left+1)
	for i := left; i <= right; i++ {
		if oneNum(i) {
			result = append(result, i)
		}
	}
	return result
}

// 求整数的各个位数 , 判断能否整除
func oneNum(num int) bool {
	static := num
	temp := 0
	for num > 0 {
		temp = num % 10
		num = num / 10
		if temp == 0 {
			//如果当前位的值位0 , 直接返回false
			return false
		}
		if temp != 0 && static%temp != 0 {
			//不能整除,不满足要求,返回false
			return false
		}
	}
	return true
}
